<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('分类统计报表')" />

</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							<label>按商品名称模糊查询：</label>
							<input type="text" name="keywords"/>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table1"></table>
		</div>
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table2"></table>
		</div>


	</div></div>

<div th:include="include :: footer"></div>
<script th:inline="javascript">
	var prefix = ctx + "demo/operate";
	var listDetails = [[${lists}]];
	var listCountAll = [[${listCountAll}]];
	$(function() {
		var options = {
			id: "bootstrap-table1",
			toolbar: "toolbar1",
			// url: prefix + "/list",
			// createUrl: prefix + "/add",
			// removeUrl: prefix + "/remove",
			// updateUrl: prefix + "/edit/{id}",
			data:listDetails,
			modalName: "详细信息",
			columns: [{
				checkbox: true
			},
				{
					field : 'projectNumber',
					title : '项目编号'
				},
				{
					field : 'unitName',
					title : '采购单位'
				},
				{
					field : 'items',
					title : '物品名称'
				},
				{
					field : 'number',
					title : '数量'
				},
				{
					field : 'price',
					title : '成交价格',
					formatter: function(value, row, index) {
						return number_format(value, 2, ".", ",");
					}
				},
				{
					field : 'amount',
					title : '采购金额(元)',
					formatter: function(value, row, index) {
						return number_format(value, 2, ".", ",");
					}
				},
				{
					field : 'supplierName',
					title : '供应商'
				},
				{
					field : 'price',
					title : '单价(元)',
					formatter: function(value, row, index) {
						return number_format(value, 2, ".", ",");
					}
				},
				{
					field : 'sumPrice',
					title : '总价(元)',
					formatter: function(value, row, index) {
						return number_format(value, 2, ".", ",");
					}
				},
				{
					field: 'createTime',
					title: '日期',
					formatter: function(value, row, index) {
						return value.substring(0,11);
					}
				},
				]
		};
		$.table.init(options);
	});


	$(function() {
		var options = {
			id: "bootstrap-table2",
			toolbar: "toolbar2",
			// url: prefix + "/list",
			// createUrl: prefix + "/add",
			// removeUrl: prefix + "/remove",
			// updateUrl: prefix + "/edit/{id}",
			data:listCountAll,
			modalName: "汇总",
			columns: [{
				checkbox: true
			},
				{
					field : 'sumNumber',
					title : '总采购个数'
				},
				{
					field : 'sumAmount',
					title : '总采购金额(元)',
					formatter: function(value, row, index) {
						return number_format(value, 2, ".", ",");
					}
				},
			]
		};
		$.table.init(options);
	});

	function options1() {
		var temp = "";
		var obj = table.config['bootstrap-table1'];
		for (var i in obj) {
			temp += i + ":" + obj[i] + "<br/>";
		}
		$.modal.alert(temp);
	}

	function options2() {
		var temp = "";
		var obj = table.config['bootstrap-table2'];
		for (var i in obj) {
			temp += i + ":" + obj[i] + "<br/>";
		}
		$.modal.alert(temp);
	}


	function number_format(number, decimals, dec_point, thousands_sep) {
		/*
    3     * 参数说明：
    4     * number：要格式化的数字
    5     * decimals：保留几位小数
    6     * dec_point：小数点符号
    7     * thousands_sep：千分位符号
    8     * */
		number = (number + '').replace(/[^0-9+-Ee.]/g, '');
		var n = !isFinite(+number) ? 0 : +number,
				prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
				sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
				dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
				s = '',
				toFixedFix = function (n, prec) {
					var k = Math.pow(10, prec);
					return '' + Math.ceil(n * k) / k;
				};

		s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
		var re = /(-?\d+)(\d{3})/;
		while (re.test(s[0])) {
			s[0] = s[0].replace(re, "$1" + sep + "$2");
		}

		if ((s[1] || '').length < prec) {
			s[1] = s[1] || '';
			s[1] += new Array(prec - s[1].length + 1).join('0');
		}
		return s.join(dec);
	}
</script>
</body>
</html>